package com.ciko.code.base;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import com.mywork.R;

/**
 * Created by ciko on 2015/12/3.
 */
public abstract class BaseListActivity extends BaseActicity implements AdapterView.OnItemClickListener {

    private ListView lvBaseActivity;
    private BaseAdapter baseAdapter;

    @Override
    protected void initLayout() {
        setContentView(R.layout.activity_base_list);
    }

    @Override
    protected void initView() {
        lvBaseActivity = (ListView) findViewById(R.id.lvBaseActivity);
        lvBaseActivity.setOnItemClickListener(this);
    }

    protected void setAdapter(BaseAdapter baseAdapter) {
        this.baseAdapter = baseAdapter;
        lvBaseActivity.setAdapter(baseAdapter);
    }

    protected void notifyDataSetChanged() {
        if (baseAdapter != null) {
            baseAdapter.notifyDataSetChanged();
        }
    }

    protected void setHeaderView(int layoutResId) {
        View handerView = LayoutInflater.from(this).inflate(layoutResId, null);
        ll_root.addView(handerView, 1);
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }
}
